package com.baofu.paycore.manager.storage.impl;

import com.baofu.paycore.service.facade.enums.PayCoreErrorCode;
import com.baofu.paycore.dal.mapper.ClearBankMapper;
import com.baofu.paycore.dal.model.ClearBankDO;
import com.baofu.paycore.manager.storage.Storage;
import com.system.commons.exception.BizServiceException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

/**
 *  充值/提现子单存储
 ** <p/>
 *      1、新增订单
 *      2、更新订单
 *      3、废弃订单
 * </p>
 * User: xin deng  Date: 16/4/27 ProjectName: paycore Version: 1.0
 */
@Slf4j
@Repository
public class ClearBankManager implements Storage<ClearBankDO> {

    /**
     * 充值/提现子单Mapper
     */
    @Autowired
    private ClearBankMapper clearBankMapper;

    /**
     * 新增订单
     *
     * @param clearBankDO 订单信息
     */
    @Override
    public int addOrder(ClearBankDO clearBankDO) {

        return clearBankMapper.insert(clearBankDO);
    }

    /**
     * 更新订单
     *
     * @param clearBankDO 订单信息
     */
    @Override
    public int modifyOrder(ClearBankDO clearBankDO) {

        return clearBankMapper.update(clearBankDO);
    }

    /**
     * 废弃订单
     *
     * @param clearBankDO 订单信息
     */
    @Override
    public int deleteOrder(ClearBankDO clearBankDO) {
        return 0;
    }

    /**
     * 获取清分银行信息
     *
     * @param payNo  支付单号
     * @return       ClearBankDO
     */
    public ClearBankDO queryClearBankInfo(String payNo) {
        log.info("获取清分银行信息,支付单号:{}", payNo);
        return clearBankMapper.queryClearBankInfo(payNo);
    }
}
